package com.szholly.pro.watergas_server.ps.android.common;

import com.szholly.plug.safe.entity.role.RoleInitHelper;

import java.util.List;

/**
 * 权限配置清单
 * 
 * 2017/3/23 <br/>
 *
 * @author Joey Huang QQ:273179370）
 */
public class SecurityConfig {
	private static final String MODULE_SECURITY_SEWAGE = "android_type_sewage";
	private static final String MODULE_SECURITY_SUPPLY = "android_type_supply";
	private static final String MODULE_SECURITY_SUPPLY_OLD = "gsaccess";
	private static final String MODULE_SECURITY_SURFACE = "android_type_surface";
	private static final String MODULE_SECURITY_POLLUTION_GAS = "android_type_pollution_gas";
	private static final String MODULE_SECURITY_POLLUTION_WATER = "android_type_pollution_water";
	private static final String MODULE_SECURITY_QC = "android_type_qc";

	private static final String QC_TASK_LAB = "android_qc_lab";
	private static final String QC_TASK_SAMPLE = "android_qc_sample";
	private static final String QC_TASK_DATA_CONTRAST = "android_qc_data_contrast";
	private static final String QC_TASK_LOCALE_CHECK = "android_qc_locale_check";
	private static final String QC_TASK_SPOT_CONTRAST = "android_qc_spot_contrast";
	private static final String QC_TASK_BLIND_CHECK = "android_qc_blind_check";
	private static final String QC_TASK_BUILD_SPOT_CONTRAST = "android_qc_build_spot_contrast";
	private static final String QC_TASK_BUILD_BLIND_CHECK = "android_qc_build_blind_check";
	
	private static final String QC_DELETE_PROCESSED_TASK = "android_qc_delete_processed_task";

	
	// private static final String QC_SPECIAL_BUILD_TASK =
	// "android_qc_special_build_task";
	private static final String QC_SPECIAL_LOOK_ALL_COMPANY = "android_qc_look_all_company";

	private static final String SEWAGE_NEED_NOT_SIGN_IN = "android_sewage_need_not_sign_in";
	private static final String SURFACE_NEED_NOT_SIGN_IN = "android_surface_need_not_sign_in";
	private static final String SUPPLY_TASK_LOCALE_CHECK = "android_supply_task_locale_check";
	private static final String SUPPLY_NEED_NOT_SIGN_IN = "android_supply_need_not_sign_in";
	private static final String SUPPLY_SPECIAL_TASK_EDIT = "android_supply_special_task_edit";

	private static final String POLLUTION_TASK_LOCALE_CHECK = "android_pollution_task_locale_check";
	
	//移动看数据权限
	private static final String MOVE_DATA_SEWAGE = "android_move_data_sewage";
	private static final String MOVE_DATA_SURFACE = "android_move_data_surface";
	private static final String MOVE_DATA_ZHUHAI = "android_move_data_zhuhai";

	
	// 模块权限
	public boolean containTypeSewage;
	public boolean containTypeSupply;
	public boolean containTypeSurface;
	public boolean containTypeQc;
	public boolean containTypePollutionGas;
	public boolean containTypePollutionWater;

	// 质控
	public boolean containTaskQcSample;
	public boolean containTaskQcLab;
	public boolean containTaskQcLocaleCheck;
	public boolean containTaskQcDataContrast;
	public boolean containTaskQcBlindCheck;
	public boolean containTaskQcSpotContrast;
	public boolean containTaskQcBuildBlindCheck;
	public boolean containTaskQcBuildSpotContrast;
	// public boolean containQcBuildTask; // 发布任务的权限
	public boolean containQcLookAllCompany;// 查看全部公司的权限
	public boolean containQcDeleteProcessedTask;// 已处理任务的删除权限

	
	
	// 供水
	public boolean containTaskSupplyLocaleCheck; // 现场考核
	public boolean containSupplyNeedNotSignIn; // 不需要签到
	public boolean containSupplyTaskEdit; // 编辑

	// 污水
	public boolean containSewageNeedNotSignIn; // 不需要签到
	// 地表水
	public boolean containSurfaceNeedNotSignIn; // 不需要签到
	public boolean containPollutionLocaleCheck;

	
	public boolean containMoveDataSewage;
	public boolean containMoveDataSurface;
	public boolean containMoveDataZhuHai;
	
	private SecurityConfig() {
	}

	private void init(List<String> list) {
		if (list != null
				&& list.size() > 0) {
			for (String permission : list) {
				/*
				 * 模块权限
				 */
				if (MODULE_SECURITY_SEWAGE.equals(permission)) {
					containTypeSewage = true;
				} else if (MODULE_SECURITY_SUPPLY.equals(permission)
						|| MODULE_SECURITY_SUPPLY_OLD.equals(permission)) {
					containTypeSupply = true;
				} else if (MODULE_SECURITY_SURFACE.equals(permission)) {
					containTypeSurface = true;
				} else if (MODULE_SECURITY_POLLUTION_GAS.equals(permission)) {
					containTypePollutionGas = true;
				} else if (MODULE_SECURITY_POLLUTION_WATER.equals(permission)) {
					containTypePollutionWater = true;
				} else if (MODULE_SECURITY_QC.equals(permission)) {
					containTypeQc = true;

					/*
					 * 质控权限
					 */
				} else if (QC_TASK_SAMPLE.equals(permission)) {// 采样
					containTaskQcSample = true;
				} else if (QC_TASK_LAB.equals(permission)) {// 实验
					containTaskQcLab = true;
				} else if (QC_TASK_DATA_CONTRAST.equals(permission)) {// 数据比对
					containTaskQcDataContrast = true;
				} else if (QC_TASK_LOCALE_CHECK.equals(permission)) {// 现场考核
					containTaskQcLocaleCheck = true;
				} else if (QC_TASK_SPOT_CONTRAST.equals(permission)) {// 抽测比对
					containTaskQcSpotContrast = true;
				} else if (QC_TASK_BLIND_CHECK.equals(permission)) {// 盲样考核
					containTaskQcBlindCheck = true;
				} else if (QC_TASK_BUILD_SPOT_CONTRAST.equals(permission)) {// 创建抽测比对
					containTaskQcBuildSpotContrast = true;
				} else if (QC_TASK_BUILD_BLIND_CHECK.equals(permission)) {// 创建盲样考核
					containTaskQcBuildBlindCheck = true;
				} else if (QC_SPECIAL_LOOK_ALL_COMPANY.equals(permission)) {// 查看全部站点
					containQcLookAllCompany = true;
				} else if (QC_DELETE_PROCESSED_TASK.equals(permission)) {// 查看全部站点
					containQcDeleteProcessedTask = true;
					/*
					 * 供水权限
					 */
				} else if (SUPPLY_TASK_LOCALE_CHECK.equals(permission)) {// 现场考核
					containTaskSupplyLocaleCheck = true;
				} else if (SUPPLY_NEED_NOT_SIGN_IN.equals(permission)) {// 签到
					containSupplyNeedNotSignIn = true;
				} else if (SUPPLY_SPECIAL_TASK_EDIT.equals(permission)) {// 签到
					containSupplyTaskEdit = true;
					/*
					 * 污水权限
					 */
				} else if (SEWAGE_NEED_NOT_SIGN_IN.equals(permission)) {
					containSewageNeedNotSignIn = true;

					/*
					 * 工业污染
					 */
				} else if (POLLUTION_TASK_LOCALE_CHECK.equals(permission)) {
					containPollutionLocaleCheck = true;
				}else if(SURFACE_NEED_NOT_SIGN_IN.equals(permission)){
                    containSurfaceNeedNotSignIn = true;
                }else if(MOVE_DATA_SEWAGE.equals(permission)){
                    containMoveDataSewage = true;
                }else if(MOVE_DATA_SURFACE.equals(permission)){
                	containMoveDataSurface = true;
                }else if(MOVE_DATA_ZHUHAI.equals(permission)){
                	containMoveDataZhuHai = true;
                }
			}
		}
	}

	public static SecurityConfig get(String userId) {
		List<String> list = RoleInitHelper.getFunctions(userId);
		return get(list);
	}

	public static SecurityConfig get(List<String> list) {
		SecurityConfig config = new SecurityConfig();
		if (list != null) {
			config.init(list);
		}
		return config;
	}
}
